import { useRef } from "react";
//登录防抖
const useDebounce = (fn, delay) => { 

    const timer = useRef();

    return (...args) => {
        clearTimeout(timer.current);

        timer.current = setTimeout(() => {
            fn(...args);
        }, delay);
    }

}

export default useDebounce;